package com.example.demo.threadDemo.athreadedCommunication;

/**
 * @Description ThreadTest
 * @Author songchuanlong
 * @Date 2025-04-16
 */

import java.sql.Timestamp;
import java.text.Format;
import java.text.SimpleDateFormat;

/**
 * 需求:3个生产者线程，负责生产包子，每个线程每次只能生产1个包子放在桌上
 * 2个消费者线程负责吃包子，每人每次只能从桌子上拿1个包子吃。
 */


public class ThreadTest {
    public static void main(String[] args) {
//        DeskDemo desk =new DeskDemo();
        DeskDemo2 desk =new DeskDemo2();
        //此线程代表厨师1
        new Thread(() -> {
            while (true) {
                desk.put();
            }
        },"厨师1").start();
        //此线程代表厨师2
        new Thread(() -> {
            while (true) {
                desk.put();
            }
        },"厨师2").start();
        //此线程代表厨师3
        new Thread(() -> {
            while (true) {
                desk.put();
            }
        },"厨师3").start();


        //此线程代表消费者1
        new Thread(() -> {
            while (true) {
                desk.get();
            }
        },"消费者1").start();
        //此线程代表消费者2

        new Thread(() -> {
            while (true) {
                desk.get();
            }
        },"消费者2").start();



    }
}
